Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TreeView] Always apply the indentation on the item content instead of its parent's group #15089

Merged
merged 16 commits into from
Nov 7, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 24, 2024

Closes #14785

  • Remove experimental feature
  • Update doc to use the new approach
  • Check all the customization demo to make sure it works correctly
  • Write migration guide

We have 3 Argos diff:

  • CustomTreeItemDemo: The indentation was broken before, the new one seems a lot better
  • ContentSlot and ContentSlotProps: There is no longer an indentation on the box, if we want to keep it we need to reset manually the padding on this item, but I don't think it's worth adding that complexity on this demo

Changelog

Tree View

  • The indentation of nested Tree Items is now applied on the content of the element.
    This is required to support features like the drag and drop re-ordering which requires every Tree Item to go to the far left of the Tree View.

    Apply custom indentation:

    If you used to set custom indentation in your Tree Item, you can use the new itemChildrenIndentation prop to do it while supporting the new DOM structure:

    <RichTreeView
      items={MUI_X_PRODUCTS}
      itemChildrenIndentation={24}
      defaultExpandedItems={['grid']}
    />

    See Tree Item Customization—Change nested item's indentation for more details.

    Fallback to the old behavior:

    If you used to style your content element (for example to add a border to it) and you don't use the drag and drop re-ordering, you can manually put the padding on the group transition element to restore the previous behavior:

    const CustomTreeItemContent = styled(TreeItemContent)(({ theme }) => ({
      // Remove the additional padding of nested elements
      padding: theme.spacing(0.5, 1),
    }));
    
    const CustomTreeItemGroupTransition = styled(TreeItemGroupTransition)({
      // Add the padding back on the group transition element
      paddingLeft: 'var(--TreeView-itemChildrenIndentation) !important',
    });

@flaviendelangle flaviendelangle self-assigned this Oct 24, 2024
@flaviendelangle flaviendelangle added breaking change component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels Oct 24, 2024
@flaviendelangle flaviendelangle marked this pull request as ready for review October 30, 2024 09:08
Copy link
Contributor

@noraleonte noraleonte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this, LGTM 🎉
I think the Argos diffs are fine 👍

@flaviendelangle flaviendelangle merged commit c2f8067 into mui:master Nov 7, 2024
18 checks passed
@flaviendelangle flaviendelangle deleted the tree-item-indentation branch November 7, 2024 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TreeView] Move the identation to the item level by default
3 participants